<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./base.js"></script>
    <script>
    
    window.onload=function(){
        var year=$('.year');
        year.onkeypress=function(){
            var regExp=/^\d{4}-\d{2}-\d{2}$/;
            if(year.value.match(regExp)){
                console.log('正确');

            }else{
                console.log('错误');
            }
        }

       
    }
    
    
    </script>
</head>
<body>
    <input type="text" class="year">
    
</body>
</html>